package com.tsmti.system.entity;

import com.tsmti.core.common.entity.BaseDataEntity;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Where;

import javax.persistence.*;

/**
 * Title：PimsSystem
 * Class：com.ts.sys.entity
 * Comapny:
 *
 * @author：zcw
 * @version：2.5 CreateTime：2018/1/16 18:23
 * Modify log:
 * Description：
 * 角色信息
 */

@Entity
@Table(name = "pims_role")
@DynamicUpdate
@DynamicInsert
@Where(clause = "delFlag = 0")
public class Role extends BaseDataEntity<Long> {
    private static final long serialVersionUID = -2469642829942293310L;

    /**id*/
    private Long id;

    /**
     * 角色编码
     */
    private String code;
    /**
     * 角色名称
     */
    private String name;

    /**
     * 是否系统数据
     */
    private String isSys;

    /**
     * 是否可用
     */
    private String usable;

    /**
     * 备注
     */
    private String remarks;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_ROLE")
    @SequenceGenerator(name = "SEQ_ROLE", sequenceName = "role_sequence", allocationSize = 1)
    @Override
    public Long getId() {
        return id;
    }

    @Override
    public void setId(Long id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIsSys() {
        return isSys;
    }

    public void setIsSys(String isSys) {
        this.isSys = isSys;
    }

    public String getUsable() {
        return usable;
    }

    public void setUsable(String usable) {
        this.usable = usable;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        result = prime * result + ((code == null) ? 0 : code.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj){
            return true;
        }
        if (obj == null){
            return false;
        }
        if (getClass() != obj.getClass()){
            return false;
        }
        Role other = (Role) obj;
        if (id == null) {
            if (other.id != null){
                return false;
            }
        } else if (!id.equals(other.id)){
            return false;
        }
        if (code == null) {
            if (other.code != null){
                return false;
            }
        } else if (!code.equals(other.code)){
            return false;
        }

        return true;
    }
}
